<!DOCTYPE html>
<html lang="en">

<head>
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
    <script type="text/javascript" src="/static/plugins/layui/layui.js"></script>

</head>

<body style="padding: 10px;">
	<form class="layui-form">
		<input type="hidden" name="id" value="{$data.item.id}">
		<div class="layui-form-item">
			<label class="layui-form-label">名称</label>
			<div class="layui-input-block">
				<input type="text" name="title" class="layui-input" value="{$data.item.title}">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">频道</label>
			<div class="layui-input-inline">
				<select name="channel_id">
					<option value="0">请选择</option>
					{volist name="data.channel" id="vo"}
					<option value="{$vo.id}" {$vo.id==$data.item.channel_id ? 'selected': '' }>{$vo.title}</option>
					{/volist}
				</select>
				
			</div>
			<label class="layui-form-label">资费</label>
			<div class="layui-input-inline">
				<select name="charge_id">
					<option value="0">请选择</option>
					{volist name="data.charge" id="vo"}
					<option value="{$vo.id}" {$vo.id==$data.item.charge_id ? 'selected' : ''}>{$vo.title}</option>
					{/volist}
				</select>
				
			</div>
		</div>
		

		<div class="layui-form-item">
			<label class="layui-form-label">地区</label>
			<div class="layui-input-inline">
				<select name="area_id">
					<option value="0">请选择</option>
					{volist name="data.area" id="vo"}
					<option value="{$vo.id}" {$vo.id==$data.item.area_id ? 'selected' : ''}>{$vo.title}</option>
					{/volist}
				</select>
			</div>

			<label class="layui-form-label">&nbsp;</label>
			<div class="layui-form-inline">
				<button type="button" class="layui-btn " onclick="turn false;" id="upload_img">
 					<i class="layui-icon">-&#xe67c;</i>上传图片
			    </button>
			    <img src="" id="pre_img" style="height: 35px;">
			    <input type="hidden" name="img" value="{$data.item.img}" >
			</div>
	    </div> 
		

		<div class="layui-form-item">
			<label class="layui-form-label">关键字</label>
			<div class="layui-input-block">
				<input type="text" name="keywords" class="layui-input" value="{$data.item.keywords}">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">影片地址</label>
			<div class="layui-input-block">
				<input type="text" name="url" class="layui-input" value="{$data.item.url}">  
			</div>
		</div>


		<div class="layui-form-item">
			<label class="layui-form-label">描述</label>
			<div class="layui-input-block">
				<input type="text" name="desc" class="layui-input" value="{$data.item.desc}">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">状态</label>
			<div class="layui-input-inline">
				<input type="checkbox" name="status" layui-skin="primary" title="发布" value="1" {$data.item.status==1?'checked':''}>
			</div>
		</div>

</form>
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" onclick="save()">保存</button>
		</div>
	</div>



	<script type="text/javascript">
		layui.use(['form','layer','upload'],function(){
			var form=layui.form;
			upload=layui.upload;
			layer=layui.layer;
			$=layui.jquery;


		//执行实例
		var uploadInst = upload.render({
			elem: '#upload_img' //绑定元素
			,url: '/admins.php/admins/video/upload_img' //上传接口
			,accept:'images'
			,done: function(res){
			  //上传完毕回调
			  $('#pre_img').attr('src',res.msg);
			  $('input[name="img"]').val(res.msg);
			}
			,error: function(){
			  //请求异常回调
			}
			});
		});


		//保存
		function save(){
			title=$.trim($('input[name="title"]').val());
			url=$.trim($('input[name="url"]').val());
			if(title==""){
				layer.alert('影片名称不能为空',{'icon':2});
			}
			if(url==""){
				layer.alert('影片地址不能为空',{'icon':2});
			}
			$.post('/admins.php/admins/video/save',$('form').serialize(),function(res){
				if(res.code>0){
					layer.alert(res.msg,{'icon':2});
				}else{
					layer.msg(res.msg);
					 setTimeout(function(){parent.window.location.reload();},1000);//父页面刷新
				}
			},'json')





		}






	</script>
	
</body>
</html>